    //
//  CommonActivityVC.m
//  SckjLoginSystem
//
//  Created by Yang on 8/6/10.
//  Copyright 2010 __MyCompanyName__. All rights reserved.
//

#import "CommonActivityVC.h"


@implementation CommonActivityVC

- (void)showLoading {
	if (loadingLabel == nil) {
		//float centerX = 160.0f;//[[UIScreen mainScreen] bounds].size.width / 2;
		//float centerY = 183.0f;//[[UIScreen mainScreen] bounds].size.height / 2;
		
		float centerX =[[UIScreen mainScreen]applicationFrame].size.width/2;
		float centerY = [[UIScreen mainScreen]applicationFrame].size.height/2;
		
		CGPoint center = CGPointMake(centerX, centerY);
		
		loadingBackImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"loading.png"]];
		loadingBackImage.frame = CGRectMake(0.0f, 0.0f, 86.0f, 24.0f);
		loadingBackImage.center = center;
		[self.view addSubview:loadingBackImage];
		
		loadingLabel = [[UILabel alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 86.0f, 24.0f)];
		loadingLabel.font = [UIFont boldSystemFontOfSize:12.0f];
		loadingLabel.backgroundColor = [UIColor clearColor];
		loadingLabel.text = @"加载中...";
		loadingLabel.textColor = [UIColor darkGrayColor];
		loadingLabel.center = CGPointMake(centerX+32, centerY);
		[self.view addSubview:loadingLabel];
		activeIndicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
		activeIndicator.center = CGPointMake(centerX - 28, centerY);
		[self.view addSubview:activeIndicator];
		
	}
	self.view.userInteractionEnabled = NO;
	loadingBackImage.hidden = NO;
	activeIndicator.hidden = NO;
	[activeIndicator startAnimating];
	loadingLabel.hidden = NO;
	[self.view bringSubviewToFront:loadingBackImage];
	[self.view bringSubviewToFront:activeIndicator];
	[self.view bringSubviewToFront:loadingLabel];
}
- (void)hideLoading {
	[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:NO];
	self.view.userInteractionEnabled = YES;
	loadingBackImage.hidden = YES;
	activeIndicator.hidden = YES;
	[activeIndicator stopAnimating];
	loadingLabel.hidden = YES;
}

- (void)dealloc {
	[loadingLabel release];
	[activeIndicator release];
	[loadingBackImage release];
    [super dealloc];
}


@end
